<?php

class HeroControl extends Control {

	public function getheros()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

        $ret = modcall("hero", "getheros", array($uid));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

    public function freshhero()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

		$cumstom = intval($_POST["cumstom"]);
        
        $ret = modcall("hero", "freshhero", array($uid, $cumstom));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

	public function hirehero()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

		$idx = intval($_POST["idx"]);
        
        $ret = modcall("hero", "hirehero", array($uid, $idx));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

	public function firehero()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

		$hid = intval($_POST["hid"]);
        
        $ret = modcall("hero", "firehero", array($uid, $hid));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

	public function openheroseat()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

        $ret = modcall("hero", "openheroseat", array($uid));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

	public function onequip()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

		$eid = intval($_POST["eid"]);
		$hid = intval($_POST["hid"]);

        $ret = modcall("hero", "onequip", array($uid, $eid, $hid));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

	public function offequip()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

		$eid = intval($_POST["eid"]);
		$hid = intval($_POST["hid"]);

        $ret = modcall("hero", "offequip", array($uid, $eid, $hid));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

}